namespace pengpeng {

export abstract class TextureData {
        public static generateRectangle(): Rectangle {
            return new Rectangle();
        }

        public rotated: boolean;
        public name: string;
        public region: Rectangle = new Rectangle();
        public frame: Rectangle;
        public parent: TextureAtlasData;

        public constructor() {
        }

        protected _onClear(): void {
            this.rotated = false;
            this.name = null;
            this.region.clear();
            this.frame = null;
            this.parent = null;
        }

        public copyFrom(value: TextureData): void {
            this.rotated = value.rotated;
            this.name = value.name;

            if (!this.frame && value.frame) {
                this.frame = TextureData.generateRectangle();
            }
            else if (this.frame && !value.frame) {
                this.frame = null;
            }

            if (this.frame && value.frame) {
                this.frame.copyFrom(value.frame);
            }

            this.parent = value.parent;
            this.region.copyFrom(value.region);
        }
    }
}